import Router from 'koa-router';
import proxyService from '../../../common/proxyService';
import {
  getRankingList, // 获取排行榜列表
  getRankingDetail, // 获取排行榜详细信息
  getRankingStatis, // 获取排行榜统计信息
  getHelpList, // 获取助力好友
  updataRanking, // 修改排行榜
  getPosterStatis, // 单个海报任务统计
  uploadCloudToken, // 获取分享图片云上传 token
} from '../../../api';

const router = new Router();

// 获取排行榜列表
router.get('/getRankingList', async ctx => {
  const response = await proxyService.postProxy(ctx, getRankingList);

  // const res = await proxyService.mockData({
  //   code: 1,
  //   message: 'ok',
  //   data: {
  //     'records|1': [
  //       {
  //         appAccountName: "玩转财富通",
  //         appHeadImageUrl: 'https://xiaodashi.com/logo.png',
  //         createTime: "2019-12-16 11:11:37",
  //         rankId: 296,
  //         rankTitle: "模拟数据--谢",
  //         activityTitle: "模拟数据--谢",
  //         rankType: 2,
  //         rewardNum: 50,
  //         rewardState: 0,
  //         statisticNum: 50,
  //       },
  //     ],
  //   },
  // });
  // response.data.records.unshift(res.data.records)

  return (ctx.body = response);
});

// 获取排行榜详细
router.get('/getRankingDetail', async ctx => {
  const response = await proxyService.postProxy(ctx, getRankingDetail);
  // response.data.rankType = 2
  return (ctx.body = response);
});

// 获取排行榜统计信息
router.get('/getRankingStatis', async ctx => {
  const response = await proxyService.postProxy(ctx, getRankingStatis);
  return (ctx.body = response);
});

// 获取助力好友
router.get('/getHelpList', async ctx => {
  const response = await proxyService.postProxy(ctx, getHelpList);
  return (ctx.body = response);
});

// 修改排行榜
router.post('/updataRanking', async ctx => {
  const response = await proxyService.postProxy(ctx, updataRanking);
  return (ctx.body = response);
});

// 单个海报任务统计
router.get('/getPosterStatis', async ctx => {
  const response = await proxyService.postProxy(ctx, getPosterStatis);
  return (ctx.body = response);
});

// 获取分享图片云上传 token
router.post('/uploadCloudToken', async ctx => {
  const response = await proxyService.postProxy(ctx, uploadCloudToken);
  return (ctx.body = response);
});

export default router;
